//
//  PaseHtmlUnit.m
//  baihewang
//
//  Created by ZhuoLaiQiang@Gmail.com on 11-5-30.
//  Copyright 2011年 Mtime. All rights reserved.
//

#import "PaseHtmlUnit.h"
#import "RootViewController.h"
#import "Element.h"
#import "DocumentRoot.h"


@implementation PaseHtmlUnit

+ (NSMutableArray*)paseRootViewData:(NSString*)html owner:(id)owner
{
    /*
     <div class="m_userlist">
     <ul>
     <li><a href="60570075.html">
     <img src="../upload/13064617344ddf062626cc6.jpg">
     <span>北京 硕士 24</span></a></li>        <li><a href="60301154.html">
     <img src="../upload/13064617344ddf06262b6fc.jpg">
     <span>北京 本科 22</span></a></li>        <li><a href="55188988.html">
     <img src="../upload/13064617344ddf062630130.jpg">
     <span>北京 硕士 28</span></a></li>        <li><a href="56744633.html">
     <img src="../upload/13064617344ddf062634f4d.jpg">
     <span>北京 硕士 27</span></a></li>        <li><a href="60135861.html">
     <img src="../upload/13064617344ddf06263959a.jpg">
     <span>北京 硕士 24</span></a></li>        <li><a href="56746514.html">
     <img src="../upload/13064617344ddf06263e3b8.jpg">
     <span>北京 博士 26</span></a></li>      </ul>
     <div class="clear"></div>
     </div>
     */
    
    DocumentRoot* document = [Element parseHTML: html];
	Element* element = [document selectElement: @"div.m_userlist"];
    NSArray *spansArray = [element selectElements: @"span"];
    NSMutableArray *infoArray = [[[NSMutableArray alloc] initWithCapacity: 6] autorelease];
    for (Element *tempE in spansArray) {
        NSString *info = [tempE contentsText];
        NSArray *tempArry = [info componentsSeparatedByString: @" "];

        NSMutableDictionary *infoDic = [NSMutableDictionary dictionaryWithObjects: tempArry forKeys: [NSArray arrayWithObjects:@"居住地", @"学 历", @"年 龄", nil] ];
        [infoArray addObject: infoDic];
    }
    
    /*
     <div class="m_story">
     <h2>成功故事</h2>
     
     
     <dl>
     <dt><img src="../upload/13064613654ddf04b53f35c.jpg" width="290" height="100" alt="mobile_update.baihe"></dt>
     <dd><strong>mobile_update.baihe</strong><br>
     她：<a class="name" href="54905528.html">悠悠</a>　　他：<a class="name" href="54012539.html">独木舟</a><br>
     感谢百合网让我们相识、相恋。让我了解到，这个世界还有这样的一个人，能让你心甘情愿为他做任何事，能让你做自己这辈子不管什么时候想起来，都不会后悔的决定。</dd>
     </dl>   
     
     <dl>
     <dt><img src="../upload/13064613654ddf04b5533a0.jpg" width="290" height="100" alt="大胖和小胖的爱情"></dt>
     <dd><strong>大胖和小胖的爱情</strong><br>
     她：<a class="name" href="54879320.html">爱花</a>　　他：<a class="name" href="55831865.html">mdkwu</a><br>
     我是一个小胖子，一直也想找个胖男孩来保护我。因为工作生活的范围狭隘，所以我注册了百合网。不久后，他关注了我。看着他相册中胖乎乎的样子，觉得他好可爱呀。</dd>
     </dl>    </div>
     */
    NSMutableArray *storyArray = [[[NSMutableArray alloc] initWithCapacity: 2] autorelease];
    DocumentRoot* documentStory = [Element parseHTML: html];
	Element* elementStory = [documentStory selectElement: @"div.m_story"];
    
    NSArray *elementArray =[elementStory selectElements: @"dl"];
    
    for (Element *element in elementArray) {
        NSString *imageUrl = [[[element selectElement: @"img"] attribute: @"src"] stringByReplacingOccurrencesOfString: @".." withString: @"http://wap.baihe.com"];
        NSString *storyTitle = [[element selectElement: @"strong"] contentsText];
       // NSLog(@"%@", storyTitle);
       // NSMusicDirectory *StoryDic = [NSMusicDirectory ];
        NSArray *elArray = [element selectElements: @"a"];
        NSString *manName     = @" ";
        NSString *womanName   = @" ";
        for (Element *element in elArray) {
            
        }
    }
    
     
}

@end
